<template>
  <el-dialog
    width="30%"
    :title=" '编辑'"
    :close-on-click-modal="false"
    :visible.sync="visible"
  >
    <div>
      <el-form ref="form" :model="dataForm" label-width="20%">
        <el-form-item label="用户名称" prop="nickname">
          <el-input v-model="dataForm.nickname" placeholder="请输入用户名称"style="width: 50%;"/>
        </el-form-item>
        <el-form-item label="真实姓名" prop="realName">
          <el-input v-model="dataForm.realName" placeholder="请输入真实姓名" style="width: 50%;"/>
        </el-form-item>
        <el-form-item label="开户行" prop="bankName">
          <el-input v-model="dataForm.bankName" placeholder="请输入开户行" style="width: 50%;"/>
        </el-form-item>
        <el-form-item label="开户支行" prop="bankAddress">
          <el-input v-model="dataForm.bankAddress" placeholder="请输入开户支行" style="width: 50%;"/>
        </el-form-item>
        <el-form-item label="手机号" prop="phone">
          <el-input v-model="dataForm.phone" placeholder="请输入手机号" style="width: 50%;"/>
        </el-form-item>
        <el-form-item label="账号" prop="bankCode">
          <el-input v-model="dataForm.bankCode" placeholder="请输入账号" style="width: 50%;"/>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer" align="right">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </div>
  </el-dialog>
</template>

<script>
import { info, edit } from '@/api/ums/bank'

export default {
  name: 'handleUpdate',
  data() {
    return {
      visible: false,
      dataList: [],
      dataForm: {
        id: '',
        isDelete: '',
        createBy: '',
        updateBy: '',
        createTime: '',
        updateTime: '',
        remark: '',
        uid: '',
        nickname: '',
        realName: '',
        bankName: '',
        bankAddress: '',
        bankCode: '',
        phone: '',
      }
    }
  },
  methods: {
    init(id) {
      this.dataForm.id = id || 0
      this.visible = true
      this.$nextTick(() => {
        if (this.dataForm.id) {
          info(this.dataForm.id).then(res => {
            this.dataForm = res.data
          })
        }
      })
    },
    /** 提交按钮 */
    submitForm() {
      edit(this.dataForm).then(response => {
        this.$message.success('修改成功')
        this.visible = false
        this.$parent.init()
      })
    },
    // 取消按钮
    cancel() {
      this.visible = false
      this.$parent.init()
    }
  }
}
</script>

<style scoped>

</style>
